﻿using System;
using System.Windows;
using System.Collections.Generic;

namespace SBPweb.Forge.Controls.Silverlight.Utilities
{

    public class Browser
    {

        private static Dictionary<string, string> queryParams;

        public static string GetQueryParameter(string name)
        {
            //return HtmlPage.Document.QueryString[name];
            if (queryParams == null)
            {
                string queryString = Application.Current.Host.Source.OriginalString.Substring(Application.Current.Host.Source.OriginalString.IndexOf('?') + 1);
                string[] split = queryString.Split(new char[] { '=', ';' }, StringSplitOptions.None);
                queryParams = new Dictionary<string, string>();
                for (int i = 0; i < split.Length - 1; i += 2)
                {
                    queryParams.Add(split[i], split[i + 1]);
                }
            }
            if (queryParams.ContainsKey(name))
            {
                return queryParams[name];
            }
            return null;
        }

    }

}